import { create } from 'zustand';

type IElementSet = {
  name: string;
  index: number;
};
type State = {
  materialSets: IElementSet[]; // 元素集
  surfaceInteractionSets: IElementSet[]; // 元素集
  boundarySets: any[]; // 元素集
};
type Action = {
  setMaterialSets: (materialSets: State['materialSets']) => void;
  setSurfaceInteractionSets: (
    surfaceInteractionSets: State['surfaceInteractionSets'],
  ) => void;
  setBoundarySets: (boundarySets: State['boundarySets']) => void;
};

/**
 * 当前表单的仿真数据
 */
export const useSimulationStore = create<State & Action>((set) => ({
  materialSets: [],
  surfaceInteractionSets: [],
  boundarySets: [], // 边界条件
  setMaterialSets: (materialSets: State['materialSets']) =>
    set(() => ({ materialSets })),
  setSurfaceInteractionSets: (
    surfaceInteractionSets: State['surfaceInteractionSets'],
  ) => set(() => ({ surfaceInteractionSets })),
  setBoundarySets: (boundarySets: State['boundarySets']) =>
    set(() => ({ boundarySets })),
}));
